package demo.api.trustsign;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import util.HttpClientUtil;
/**
 * 文档验证
 *
 * @throws IOException
 */
public class FileVerify {
	private static String appKey = "cAwut4VATycNMq17NZeFUD63pe83l2OJ";
    private static String appSecrty = "3BAlrfr7lW8kwlCMfo1dXS8Syn5q5qjS";
    private static String baseUrl = "http://smp-test.szitrus.com.cn/smp-api";
    private static String api = "/api/trustsign/file/verify";

	public static void main(String[] args) throws IOException {
		String url = baseUrl.concat(api);
		// 请求参数
        Map<String, String> params = new HashMap<>();
        params.put("file_data", Base64.encodeBase64String(FileUtils.readFileToByteArray(new File("D:/smp_temp/test.pdf"))));

	    String resStr =  HttpClientUtil.getResponse(url, params, appKey, appSecrty);
	    JSONObject resJson = JSON.parseObject(resStr);	
	    System.out.println(resJson);
	}
}
